#include <bits/stdc++.h>
#include "merge_span.h"
using namespace std;
vector<pair<int,int>> merge_span(vector<pair<int,int>>& a)
{
    assert(a.size()>0);
    sort(a.begin(),a.end());
    int begin = 0,end = 0;
    vector<pair<int,int>> tmp;
    tmp.push_back(a[0]);
    for(int i=1;i<a.size();i++)
    {
        if(a.at(i).first<tmp.back().second)
            tmp.back().second = max(a.at(i).second,tmp.back().second);
        else
            tmp.push_back(a[i]);
    }
    return tmp;
}

